﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace SF.Base.Core
{
	public class BaseControl : System.Web.UI.UserControl
	{
		protected override void OnError(EventArgs e)
		{
			Exception ex = Server.GetLastError();
			if (ex != null)
			{
				Logger.Exception(ex);
				Server.ClearError();
			}
		}

		protected UserEntity DTUser {
			get {
				if (HttpContext.Current.Session["_DT_USER_"] == null) {
					return null;
				}
				return HttpContext.Current.Session["_DT_USER_"] as UserEntity;
			}
		}

		protected string UserId{
			get {
				if (HttpContext.Current.Session["_DT_USER_"] == null) {
					return Guid.Empty.ToString();
				}
				return (HttpContext.Current.Session["_DT_USER_"] as UserEntity).UserId.ToString();
			}
		}

		protected long UID {
			get {
				if (HttpContext.Current.Session["_DT_USER_"] == null) {
					return -1;
				}
				return (HttpContext.Current.Session["_DT_USER_"] as UserEntity).UID;
			}
		}
	}
}
